﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace SilverPOP.Library.Utilities
{
    public class NammingGenerator
    {
        public static string CreateCleanUrl(string name, string extension)
        {
            string fileName = Regex.Replace(name, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            fileName = Regex.Replace(fileName, @"[\s]+", "-", RegexOptions.Compiled).ToLowerInvariant() + "." + extension;
            return fileName;
        }

        public static string CreateCleanUrl(string name)
        {
            string value = Regex.Replace(name, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            value = Regex.Replace(value, @"[\s]+", "-", RegexOptions.Compiled).ToLowerInvariant() + ".aspx";
            return value;
        }

        public static string CreateCleanTextForUrl(string name)
        {
            string value = Regex.Replace(name, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            value = Regex.Replace(value, @"[\s]+", "-", RegexOptions.Compiled).ToLowerInvariant();
            return value;
        }


        public static string GenerateSilverpopIdentifierName(string campaignName,SilverpopNammingPostFix postFix)
        {
            string value = Regex.Replace(campaignName, @"[^a-zA-Z0-9_\s]+", "", RegexOptions.Compiled).ToLowerInvariant();
            value = Regex.Replace(value, @"[\s]+", "-", RegexOptions.Compiled).ToLowerInvariant();
            return string.Format("{0}_{1}", value, postFix.ToString());
        }    
    
    
    }//end class

    
}
